package com.sutuijingling.result;

import com.sutuijingling.utils.d;
import com.sutuijingling.utils.f;
import java.io.File;
import java.nio.charset.Charset;
import java.util.Map.Entry;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.mime.content.b;
import org.apache.http.entity.mime.content.c;
import org.apache.http.entity.mime.e;
import org.apache.http.entity.mime.j;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public abstract class a {
    public static String e = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";
    public static int f = 96;
    protected b a;
    protected int b = 1;
    protected int c = WorkStatus.ItemViewShopName;
    protected File d;

    protected abstract f a();

    protected abstract String b();

    public Object c() throws c {
        HttpUriRequest a;
        if (this.d == null) {
            a = this.a.a(this.d);
        } else {
            final j a2 = j.a();
            a2.a(e.BROWSER_COMPATIBLE);
            a2.a(Charset.forName("UTF-8"));
            a2.a("errorImg", new b(this.d));
            new d(this, this.a.a()) {
                final /* synthetic */ a b;

                public void a(Entry entry) {
                    a2.a((String) entry.getKey(), new c((String) entry.getValue(), org.apache.http.entity.b.h));
                }
            }.a();
            HttpEntity c = a2.c();
            this.a.a(true);
            HttpPost httpPost = new HttpPost(this.a.a(this.d).getURI());
            httpPost.setEntity(c);
            Object obj = httpPost;
        }
        HttpConnectionParams.setSoTimeout(a.getParams(), this.c);
        HttpConnectionParams.setConnectionTimeout(a.getParams(), this.c);
        a.getParams().setParameter("http.protocol.allow-circular-redirects", Boolean.valueOf(true));
        a.getParams().setParameter("http.protocol.max-redirects", Integer.valueOf(20));
        HttpClient defaultHttpClient = new DefaultHttpClient();
        HttpParams params = defaultHttpClient.getParams();
        HttpConnectionParams.setSoTimeout(params, 30000);
        HttpConnectionParams.setConnectionTimeout(params, 30000);
        while (true) {
            int i = this.b;
            this.b = i - 1;
            if (i > 0) {
                try {
                    break;
                } catch (Exception e) {
                    if (e.getClass().isAssignableFrom(c.class)) {
                        throw ((c) e);
                    }
                    System.err.println("error >>>>> request uri: " + a.getURI().toString());
                    e.printStackTrace();
                }
            } else {
                throw new c(HttpStatus.SC_BAD_REQUEST);
            }
        }
        return a().a(defaultHttpClient.execute(a));
    }
}
